#include <bits/stdc++.h>
//I hate CCF!
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const ld eps=1e-16;
struct car{
    int d,a,p,be,ed,of;
    void c(){d=a=p=be=ed=of=0;}
}co[114514];
int ff[114514];
int ms=114514,cnt=0;
void dfs(int dep,int n,int m,string chos){
    if(dep==m+1){
        int ans=0,ce=0;
        for(int i=0;i<chos.size();i++)if(chos[i]=='0')ce++;
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                if(chos[j]=='1'){
                    if(co[i].of==0&&co[i].be<=ff[j]&&ff[j]<=co[i].ed){
                        ans++;
                        co[i].of=1;
                    }
                }
            }
        }
        if(ans==cnt){
            ms=min(ms,ce);
        }
        return;
    }
    dfs(dep+1,n,m,chos+"1");
    dfs(dep+1,n,m,chos+"0");
}
void mian(){
    int n,m,len,speed;cin>>n>>m>>len>>speed;
    ms=114514;
    int cheat=1,cheat2=1;
    vector<int> fuckCCF(1000005,0);
    for(int i=1;i<=n;i++){
        co[i].c();
        cin>>co[i].d>>co[i].a>>co[i].p;
        int a=co[i].a,p=co[i].p,d=co[i].d;
        if(p>0){
            cheat&=1;cheat2&=0;
            if(a>speed){
                co[i].be=d;co[i].ed=len+1;
            }else{
                co[i].ed=len+1;
            }
        }else if(p==0){
            cheat&=1;cheat2&=0;
            if(a<=speed){
                co[i].be=co[i].ed=len+3;
            }else{
                co[i].be=d;co[i].ed=len+1;
            }
        }else{
            cheat&=0;cheat2&=1;
            if(a<=speed){
                co[i].be=co[i].ed=len+3;
            }else{
                co[i].be=d;
                ld er=((ld)(speed)*(ld)(speed)-(ld)(a)*(ld)(a))/(2.0*p);
                co[i].ed=d+er-eps;
                if(co[i].ed>len)co[i].ed=len+1;
            }
        }
    }
    if(cheat){
        cnt=0;
        for(int i=1;i<=m;i++){
            int f;cin>>f;
            ff[i]=f;
            fuckCCF[f]++;
        }
        for(int i=1;i<=len+5;i++){fuckCCF[i]+=fuckCCF[i-1];}
        for(int i=1;i<=n;i++){
            if(fuckCCF[co[i].ed]-fuckCCF[co[i].be-1])cnt++;
        }
        cout<<cnt<<" "<<(m-1)+(cnt==0)<<endl;
    }else{
        cnt=0;
        for(int i=1;i<=m;i++){
            int f;cin>>f;
            ff[i]=f;
            fuckCCF[f]++;
        }
        for(int i=1;i<=len+5;i++){fuckCCF[i]+=fuckCCF[i-1];}
        for(int i=1;i<=n;i++){
            if(fuckCCF[co[i].ed]-fuckCCF[co[i].be-1])cnt++;
        }
        cout<<cnt<<" ";
        dfs(1,n,m,"");
        cout<<ms<<endl;
    }
}

int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    //cheating
    int T;cin>>T;
    while(T--)mian();
    return 0;
}
/*
1
5 5 15 3
0 3 0
12 4 0
1 1 4
5 5 ‐2
6 4 ‐4
2 5 8 9 15
*/
